# Maintainer: Frode Solheim <frode@fs-uae.net>

_realname=lhafile
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-lhafile"
         "${MINGW_PACKAGE_PREFIX}-python3-lhafile")
pkgver=0.2.1
pkgrel=2
pkgdesc="LHA module for Python (mingw-w64)"
arch=('any')
license=('BSD')
url="https://fengestad.no/python-lhafile"
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3")
options=('staticlibs' 'strip' '!debug')
source=(http://fengestad.no/python-lhafile/python-lhafile-${pkgver}.tar.gz)
sha256sums=('ccddfa7312d08a48159fa702c5e92efcc0e341d580e4dfb2c5a1bbdc2704e35e')

prepare() {
  cp -a python-lhafile-${pkgver} python2-lhafile-${pkgver}-${CARCH}
  cp -a python-lhafile-${pkgver} python3-lhafile-${pkgver}-${CARCH}
}

build() {
  echo "Building for Python 2"
  cd python2-lhafile-${pkgver}-${CARCH}
  ${MINGW_PREFIX}/bin/python2 setup.py build
  cd ..

  echo "Building for Python 3"
  cd python3-lhafile-${pkgver}-${CARCH}
  ${MINGW_PREFIX}/bin/python3 setup.py build
}

package_python2-lhafile() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2"
           "${MINGW_PACKAGE_PREFIX}-python2-six")

  cd python2-lhafile-${pkgver}-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -m755 -d "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-lhafile"
  install -m644 COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-lhafile/"
}

package_python3-lhafile() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3"
           "${MINGW_PACKAGE_PREFIX}-python3-six")

  cd python3-lhafile-${pkgver}-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -m755 -d "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-lhafile"
  install -m644 COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-lhafile/"
}

package_mingw-w64-i686-python2-lhafile() {
  package_python2-lhafile
}

package_mingw-w64-i686-python3-lhafile() {
  package_python3-lhafile
}

package_mingw-w64-x86_64-python2-lhafile() {
  package_python2-lhafile
}

package_mingw-w64-x86_64-python3-lhafile() {
  package_python3-lhafile
}
